<template>
  <view class="curriulum-list">
    <!-- <view class="curriulum-item" v-for="(item, i) in PjList.datas" :key="i" @click="gotoPj1228(item)">
      <view class="curriulum-name">{{item.class_name}}</view>
      <uni-icons type="arrowright" size="16"></uni-icons>
    </view> -->
    <uni-section :title="'课程名称：' +queryObj.cid+'.'+ queryObj.cname" type="line">
      <uni-list v-for="(item, i) in PjList.datas" :key="i">
        <uni-list-item showArrow :title="item.class_name" :note="item.teacher_name" :rightText="item.year_term"
          clickable @click="gotoPj1228(item)" />
      </uni-list>
    </uni-section>

  </view>
</template>

<script>
  export default {
    data() {
      return {
        // 上个网页传的数据，课程名称id
        queryObj: {
          cid: '',
          cname: ''
        },
        PjList: []
      }
    },
    onLoad(options) {
      // 将页面参数转存到 this.queryObj 对象中
      console.log(options)
      this.queryObj.cid = options.subject || ''
      this.queryObj.cname = options.curriulum_name || ''
      this.getPj1227Results()
    },
    methods: {
      gotoPj1228(item) {
        console.log(item)
        uni.navigateTo({
          url: '../pj1228/pj1228?curriulum_id=' + this.queryObj.cid + '&curriulum_name=' + this.queryObj
            .cname + '&aproject_id=' + item.aproject_id
        })
      },
      async getPj1227Results() {
        const {
          data: res
        } = await uni.$http.get('?command=pj1227&subject=' + this.queryObj.cid)
        console.log(res)
        this.PjList = res.data
      }
    }
  }
</script>

<style lang="scss">
  .curriulum-list {
    padding: 0 5px;

    .curriulum-item {
      font-size: 12px;
      padding: 13px 0;
      border-bottom: 1px solid #efefef;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .curriulum-name {
        // 文本不允许换行
        white-space: nowrap;
        // 溢出部分隐藏
        overflow: hidden;
        // 文本溢出后，使用。。。代替
        text-overflow: ellipsis;
        margin-right: 3px;
      }
    }
  }
</style>
